package com.open.admin.controller;


import com.open.system.anno.IgnoreWebSecurity;
import com.open.system.domain.TokenUserInfo;
import com.open.system.utils.JwtUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin")
public class TestController {



    @IgnoreWebSecurity
    @GetMapping("/token")
    public Object createToken(){

        TokenUserInfo admin = TokenUserInfo.builder()
                .userId(1L)
                .username("admin")
                .build();


        return JwtUtils.getToken(admin);
    }

    @PreAuthorize("hasAuthority('test')")
    @RequestMapping("/test")
    public Object get(){
        return 123;
    }
}
